<?php
/**
 * Created by PhpStorm.
 * User: serenehaly
 * Date: 2018/2/2
 * Time: 15:24
 */

namespace app\api\controller\v1;


use app\api\validate\IDCollection;
use app\api\model\Theme as ThemeModel;
use app\api\validate\PositiveInteger;
use app\lib\exception\ThemeException;

class Theme
{
    public function getSimpleList($ids = '')
    {
        $validate = new IDCollection();
        $validate->goCheck();
        $theme = ThemeModel::with(['topicImg', 'headImg'])->select($ids);
        if (!$theme) {
            throw new ThemeException();
        } else {
            return $theme;
        }
    }

    public function getComplexOne($id)
    {
        (new PositiveInteger())->goCheck();
        $theme = ThemeModel::getThemeWithProducts($id);
        if (!$theme) {
            throw new ThemeException();
        } else {
            return $theme;
        }
    }
}